using System.ComponentModel.DataAnnotations;

namespace DaoHang.Models
{
    /// <summary>
    /// 管理员用户实体类，用于存储管理员账号信息
    /// </summary>
    public class User
    {
        /// <summary>
        /// 用户ID，主键
        /// </summary>
        [Key]
        public int Id { get; set; }

        /// <summary>
        /// 用户名，最大长度50字符，不可为空，唯一
        /// </summary>
        [Required(ErrorMessage = "用户名不能为空")]
        [MaxLength(50, ErrorMessage = "用户名不能超过50个字符")]
        public string Username { get; set; } = string.Empty;

        /// <summary>
        /// 密码哈希值，不可为空
        /// </summary>
        [Required(ErrorMessage = "密码不能为空")]
        public string PasswordHash { get; set; } = string.Empty;

        /// <summary>
        /// 邮箱地址，最大长度100字符
        /// </summary>
        [MaxLength(100, ErrorMessage = "邮箱地址不能超过100个字符")]
        [EmailAddress(ErrorMessage = "请输入有效的邮箱地址")]
        public string? Email { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 是否为超级管理员
        /// </summary>
        public bool IsAdmin { get; set; } = true;
    }
} 